package com.woniuxy.oldmanapi.controller;

import com.woniuxy.oldmanapi.entity.Category;
import com.woniuxy.oldmanapi.entity.CategoryType;
import com.woniuxy.oldmanapi.service.CategoryService;
import com.woniuxy.oldmanapi.service.CategoryTypeService;
import com.woniuxy.oldmanapi.vo.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@RestController
public class CategoryTypeController {
    @Autowired
    CategoryTypeService categoryTypeService;

    //查询咨询者信息
    @GetMapping("/categoryType/selectById/{id}")
    public ResponseResult<List<CategoryType>> selectById(@PathVariable(value = "id")int id){
        ResponseResult<List<CategoryType>> result = new ResponseResult<>();
        try {
            List<CategoryType> list = categoryTypeService.selectById(id);
            result.setCode(200);
            result.setMsg("查询成功");
            result.setData(list);
        } catch (Exception e) {
            e.printStackTrace();
            result.setCode(203);
            result.setMsg("系统错误，请联系管理员!!!");
        }
        return result;
    }
}
